package com.beiben.statistics.controller;


import com.beiben.statistics.service.ICompositeService;
import com.beiben.statistics.vo.CompositeDateVo;
import com.beiben.statistics.vo.LineDataVo;
import com.beiben.statistics.vo.NameValueVo;
import com.beiben.statistics.vo.RecordSearchParamVo;
import com.ruoyi.common.exception.BaseException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;
import java.util.List;

/**
 * 综合工时统计看板Controller
 *
 * @author xgq
 * @date 2020-10-09
 */
@RestController
@RequestMapping("/statistics/composite")
public class CompositeController {

    @Autowired
    private ICompositeService compositeService;


    /**
     * 查询所的总工时
     */
    @PostMapping("/dept/suo")
    @ResponseBody
    public List<CompositeDateVo>  selectAbilityDeptSuo(RecordSearchParamVo recordSearchParamVo, HttpServletRequest request, HttpServletResponse response){
        List<CompositeDateVo> list = null;
        try {
            list = compositeService.selectWorkDeptSuo(recordSearchParamVo);
        } catch (ParseException e) {
            e.printStackTrace();
            throw new BaseException("日期转换错误");
        }
        return list;
    }


    /**
     * 查询科室的总工时
     */
    @PostMapping("/dept/shi")
    @ResponseBody
    public List<CompositeDateVo> selectAbilityDeptShi(RecordSearchParamVo recordSearchParamVo, HttpServletRequest request, HttpServletResponse response){
        List<CompositeDateVo> list = null;
        try {
            list = compositeService.selectWorkDeptShi(recordSearchParamVo);
        } catch (ParseException e) {
            e.printStackTrace();
            throw new BaseException("日期转换错误");
        }
        return list;
    }




    /**
     * 查询所的工作饱和度
     */
    @PostMapping("/dept/ave/suo")
    @ResponseBody
    public List<CompositeDateVo> selectAbilityDeptAverageSuo(RecordSearchParamVo recordSearchParamVo, HttpServletRequest request, HttpServletResponse response){
        List<CompositeDateVo> list = null;
        try {
            list = compositeService.selectAbilityDeptAverageSuo(recordSearchParamVo);
        } catch (ParseException e) {
            e.printStackTrace();
            throw new BaseException("日期转换错误");
        }
        return list;
    }

    /**
     * 查询科室的平均工作工时
     */
    @PostMapping("/dept/ave/shi")
    @ResponseBody
    public List<CompositeDateVo> selectAbilityDeptAverageShi(RecordSearchParamVo recordSearchParamVo, HttpServletRequest request, HttpServletResponse response){
        List<CompositeDateVo> list = null;
        try {
            list = compositeService.selectAbilityDeptAverageShi(recordSearchParamVo);
        } catch (ParseException e) {
            e.printStackTrace();
            throw new BaseException("日期转换错误");
        }
        return list;
    }

    /**
     * 查询人员总工时
     */
    @PostMapping("/dept/people")
    @ResponseBody
    public List<CompositeDateVo> selectWorkTotalPeople(RecordSearchParamVo recordSearchParamVo, HttpServletRequest request, HttpServletResponse response){
        List<CompositeDateVo> list = null;
        try {
            list = compositeService.selectWorkTotalPeople(recordSearchParamVo);
        } catch (ParseException e) {
            e.printStackTrace();
            throw new BaseException("日期转换错误");
        }
        return list;
    }
    /**
     * 查询人员工作饱和度
     */
    @PostMapping("/dept/avg/people")
    @ResponseBody
    public List<CompositeDateVo> selectWorkAvgPeople(RecordSearchParamVo recordSearchParamVo, HttpServletRequest request, HttpServletResponse response){
        List<CompositeDateVo> list = null;
        try {
            list = compositeService.selectWorkAvgPeople(recordSearchParamVo);
        } catch (ParseException e) {
            e.printStackTrace();
            throw new BaseException("日期转换错误");
        }
        return list;
    }
    /**
     * 查询人员项目总量曲线（近30天）
     */
    @PostMapping("/total/line/people")
    @ResponseBody
    public List<CompositeDateVo> selectTotalLinePeople( RecordSearchParamVo recordSearchParamVo, HttpServletRequest request, HttpServletResponse response) {
        List<CompositeDateVo> list = null;
        try {
            list = compositeService.selectWorkLinePeople(recordSearchParamVo);
        } catch (ParseException e) {
            e.printStackTrace();
            throw new BaseException("日期转换错误");
        }
        return list;
    }

    /**
     * 查询人员工作饱和度曲线（近30天）
     */
    @PostMapping("/avg/line/people")
    @ResponseBody
    public List<CompositeDateVo> selectAvgLinePeople(RecordSearchParamVo recordSearchParamVo, HttpServletRequest request, HttpServletResponse response){
        List<CompositeDateVo> list = null;
        try {
            list = compositeService.selectWorkAvgLinePeople(recordSearchParamVo);
        } catch (ParseException e) {
            e.printStackTrace();
            throw new BaseException("日期转换错误");
        }
        return list;
    }
}
